/**
 * 可达性统计
 * 拓扑排序 DAGDP bitset 链式前向星
 */

#include <bits/stdc++.h>
using namespace std;
const int N = 3e4 + 10;
bitset<N> f[N];
int edge[N], head[N], ver[N], deg[N], tot, cnt, n, m;
vector<int> order;
void add(int x, int y) {
  ver[++tot] = y;
  edge[tot] = head[x];
  head[x] = tot;
  deg[y]++;
}
void topsort() {
  queue<int> q;
  for (int i = 1; i <= n; ++i)
    if (deg[i] == 0) q.push(i);
  while (q.size()) {
    int x = q.front();
    order.push_back(x);
    q.pop();
    for (int i = head[x]; i; i = edge[i]) {
      int y = ver[i];
      if (--deg[y] == 0) q.push(y);
    }
  }
}
void calc() {
  for (int j = order.size() - 1; j >= 0; --j) {
    int x = order[j];
    f[x][x] = 1;
    for (int i = head[x]; i; i = edge[i]) {
      int y = ver[i];
      f[x] |= f[y];
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    add(x, y);
  }
  topsort();
  calc();
  for (int i = 1; i <= n; ++i) cout << f[i].count() << endl;
}
